package com.igeek.javase.ch03;

/*
 *@author wangpeng
 *2023/7/12 18:08
 *@description 成绩计算类
 */

public class Calculate {
    //属性
    private float javagrade,sqlgrade,cgrade;

    //无参构造
    public Calculate(){

    }

    //有参构造
    public Calculate(float j, float s, float c) {
        this.javagrade=j;
        this.sqlgrade=s;
        this.cgrade=c;
    }

    public float getJavagrade() {
        return javagrade;
    }

    public void setJavagrade(float javagrade) {
        this.javagrade = javagrade;
    }

    public float getSqlgrade() {
        return sqlgrade;
    }

    public void setSqlgrade(float sqlgrade) {
        this.sqlgrade = sqlgrade;
    }

    public float getCgrade() {
        return cgrade;
    }

    public void setCgrade(float cgrade) {
        this.cgrade = cgrade;
    }
    public void show(){
        System.out.println("Java成绩："+ javagrade+" SQL成就：" + sqlgrade + " C#成绩：" + cgrade);
    }
    public void avag()
    {
        System.out.println("平均成绩："+(javagrade+sqlgrade+cgrade)/3);
    }
    public void add()
    {
        System.out.println("总成绩："+(javagrade+sqlgrade+cgrade));
    }
    public static void main(String[] args) {
        System.out.println("【成绩计算类实现】");
        Calculate cal1 = new Calculate();
        cal1.javagrade = 91.0F;
        cal1.sqlgrade = 92.0F;
        cal1.cgrade = 93.0F;
        System.out.println("使用无参构造显示输出：");
        cal1.show();
        cal1.add();
        cal1.avag();
        System.out.println(" ");

        Calculate cal2 = new Calculate(95.0F,96.0F,97.0F);
        System.out.println("使用有参构造显示输出：");
        cal2.show();
        cal2.avag();
        cal2.add();
    }
}
